package test0ne.多线程;

import java.util.concurrent.*;

public class ExecutorTest {

    private ExecutorService service = Executors.newFixedThreadPool(10);

    public static void main(String[] args) {
        Call task = new Call("world");
        ExecutorService e = Executors.newFixedThreadPool(4);
        FutureTask<String> futureTask = (FutureTask<String>) e.submit(task);

        try {
            System.out.println(futureTask.get());
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        } catch (ExecutionException ex) {
            ex.printStackTrace();
        }

    }

    private static class Run implements Runnable{

        @Override
        public void run() {

        }
    }

    private static class Call implements Callable{

        private String msg;

        public Call(String msg) {
            this.msg = msg;
        }

        @Override
        public String call() throws Exception {
            return "hello "+ msg + "!";
        }
    }
}
